﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Marbles.Core.Content.Themes
{
    public class ThemeFile : IComparable<ThemeFile>
    {

        public string ApplicationPath { get { return _filename; } }
        public string ContentType { get { return _contenttype; } }
        public string Name { get { return _name; } }
        public string FullName { get { return _fullname; } }
        public string Extension { get { return _extension; } }
        public string IconUrl { get { return _iconurl; } }
        public string DirectoryName { get { return _DirectoryName; } }
        public string VirtualPath { get { return DirectoryName + Name + Extension; } }

        private string _iconurl = string.Empty;
        private string _extension = string.Empty;
        private string _filename = string.Empty;
        private string _contenttype = string.Empty;
        private string _name = string.Empty;
        private string _DirectoryName = string.Empty;
        private string _fullname = string.Empty;

        public ThemeFile(string Filename, string DirectoryName)
        {
            FileInfo info = new FileInfo(Filename);
            _fullname = info.Name;
            _filename = info.FullName;
            _DirectoryName = DirectoryName;
            _name = System.IO.Path.GetFileNameWithoutExtension(info.FullName);
            _extension = info.Extension;
            _contenttype = Content.ContentTypes.GetMimeType(_extension);
            _iconurl = Content.ContentTypes.GetIconUrl(_contenttype);
            if (_contenttype.StartsWith("image/"))
            {
                _iconurl = "Thumbnail.axd?name=" + VirtualPath + "&w=64&h=64";
            }
        }

        public override string ToString()
        {
            return Name;
        }

        public int CompareTo(ThemeFile other)
        {
            return this.ToString().CompareTo(other.ToString());
        }
    }
}